Switch vtpm device setup/teardown over to xstransact.
authorcl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Mon, 12 Sep 2005 19:59:40 +0000 (19:59 +0000)
committercl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Mon, 12 Sep 2005 19:59:40 +0000 (19:59 +0000)
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
tools/python/xen/xend/XendDomainInfo.py

index 1ebfe08bb8ef67570e73553cc462dbdf9441ac9b..1990e7b51fb791a5445c16de65beb4c24df7bf7d 100644 (file)
@@ -473,22 +473,19 @@ class XendDomainInfo:
             devnum = int(sxp.child_value(devconfig, 'instance', '0'))
             log.error("The domain has a TPM with instance %d." % devnum)
 
-            # create backend db
-            backdb = backdom.db.addChild("/backend/%s/%s/%d" %
-                                         (type, self.uuid, devnum))
-            # create frontend db
-            db = self.db.addChild("/device/%s/%d" % (type, devnum))
-
-            backdb['frontend'] = db.getPath()
-            backdb['frontend-id'] = "%i" % self.id
-            backdb['instance'] = sxp.child_value(devconfig, 'instance', '0')
-            backdb.saveDB(save=True)
-
-            db['handle'] = "%i" % devnum
-            db['backend'] = backdb.getPath()
-            db['backend-id'] = "%i" % int(sxp.child_value(devconfig,
-                                                          'backend', '0'))
-            db.saveDB(save=True)
+            backpath = "%s/backend/%s/%s/%d" % (backdom.path, type,
+                                                self.uuid, devnum)
+            frontpath = "%s/device/%s/%d" % (self.path, type, devnum)
+
+            front = { 'backend' : backpath,
+                      'backend-id' : "%i" % backdom.id,
+                      'handle' : "%i" % devnum }
+            xstransact.Write(frontpath, front)
+
+            back = { 'instance' : "%i" % devnum,
+                     'frontend' : frontpath,
+                     'frontend-id' : "%i" % self.id }
+            xstransact.Write(backpath, back)
 
             return
 
@@ -795,14 +792,9 @@ class XendDomainInfo:
             t.remove(d)
         for d in t.list("vif"):
             t.remove(d)
+        for d in t.list("vtpm"):
+            t.remove(d)
         t.commit()
-        ddb = self.db.addChild("/device")
-        for type in ddb.keys():
-            if type == 'vtpm':
-                typedb = ddb.addChild(type)
-                for dev in typedb.keys():
-                    typedb[dev].delete()
-                typedb.saveDB(save=True)
 
     def show(self):
         """Print virtual machine info.